<div class="dt cw-icon"><i class="ci-right">></i><a href="<{link app=b2c ctl=site_member act=index}>"><{$setting.title}></a></div>
<div class="dd dorpdown-layer">
  <div class="dd-spacer"></div>
  <div class="userinfo">
<!--     <div class="u-pic">
    	<{if $data.member_id}>
        <a href="<{link app=b2c ctl=site_member act=index}>"><img width="60" height="60" src="<{$data.lv_logo|default:$setting.userimg}>" alt="<{$data.levelname}>"  /></a>        
        <{else}>
        <a href="<{link app=b2c ctl=site_passport act=login}>"><img width="60" height="60" src="<{$setting.guestimg}>" alt="游客" /></a>
        <{/if}>       
    </div> -->
    <div class="u-login">        
        <{if $data.member_id}>
        <a href="<{link app=b2c ctl=site_member act=index}>" class="link-login"><{$data.uname}></a>
    	<a class="user-level<{$data.member_lv}>" target="_blank" href="<{link app=b2c ctl=site_member act=index}>" id="userLevel" title="<{$data.levelname}>"></a>
        <{else}>
        <a href="<{link app=b2c ctl=site_member act=index}>" class="link-login">你好，请登录</a>
        <{/if}>
    </div>
    <div class="u-extra"><a href="<{link app=b2c ctl=site_member act=inbox}>">消息<{if $data.newmsg > 0}><span id="num-tip">&nbsp;<{$data.newmsg}>&nbsp;</span><{/if}></a></div>
  </div>
  <div class="otherlist">
    <div class="fore1">      
     <div class="item"><a href="<{link app=b2c ctl=site_member act=favorite}>">我的收藏<{if $data.favorite > 0}><span id="num-favorite">&nbsp;<{$data.favorite}>&nbsp;</span><{/if}></a></div>
      <!-- <div class="item"><a href="<{link app=b2c ctl=site_member act=notify}>">到货通知<{if $data.sto_goods_num > 0}><span id="num-reduction">&nbsp;<{$data.sto_goods_num}>&nbsp;</span><{/if}></a></div> -->

      <!-- 判断支付方式是否开启预存款 -->
	 <{if $data.app_staus == 'true'}>
	      <div class="item"><a href="<{link app=b2c ctl=site_member act=balance}>">我的预存款
	     
	      </a></div>
   <{/if}>

   
    </div>
    <div class="fore2">
      <div class="item"><a href="<{link app=b2c ctl=site_member act=orders}>">我的订单<{if $data.neworder > 0}><span id="num-unfinishedorder">&nbsp;<{$data.neworder}>&nbsp;</span><{/if}></a></div>
	

    </div>
  </div>
  <div class="viewlist" id="box_hst" style="display:none">
    <div class="smt clearfix">
      <h4>最近浏览</h4>
      <span class="extra"><a href="<{link app=b2c ctl=site_tools act=history}>" target="_blank">更多&nbsp;&gt;</a></span>
    </div>
    <div class="smc clearfix" ></div>
  </div>
</div>
<div class="spacer"></div>
<script>
withBrowserStore(function(browserStore){
	var box=$('box_hst');
	browserStore.get('history', function(rs) {
		rs = JSON.decode(rs);
		var min = 1;
		if (!rs || rs.length <= min) return;
		box.show();
		var html='';
		var template= '<div class="item">';
			template+='<a href="<{link app=b2c ctl=site_product act=index arg0="{goodsId}"}>" target="_blank" title="{goodsName}" data-gid="{goodsId}"><img src="{goodsImg}" alt="{goodsName}" /></a>'.replace('index-','');
			template+= '</div>';
			
		var max=Math.min(rs.length,'<{$setting.max|default:5}>');
		rs.each(function(goods,index){
			if(index >= min && index <= max){
				if(index == max - 1){
					goods['last'] = 'last';
				}
				html += template.substitute(goods);
			}
		});
		box.getElement('.smc').innerHTML = html;
		box.getElements('.item a').each(function(item) {
			var img = item.getElement('img');
			img.zoomImg(50,50);
			img.onerror = function(){
				imgRequest(item, img, rs, min, max);
			}
			if (!img.get('src')) {
				imgRequest(item, img, rs, min, max);
			}
		});
	});
	function imgRequest(el, img, rs, min, max) {
		var gid = el.get('data-gid');
		new Request.JSON({
			url: "<{link app=b2c ctl=site_product act=picsJson}>",
			onComplete: function(data) {
				new Asset.image(data, {
					onload: function() {
						img.src = data;
						img.zoomImg(50,50);
					},
					onerror: function() {
						el.set('text', '<{t}>图片加载失败<{/t}>');
					}
				});

				rs.map(function(goods, index) {
					if (index >= min && index <= max && goods['goodsId'] == gid) return goods['goodsImg'] = data;
				});
				browserStore.set('history', JSON.encode(rs));
			}
		}).get({'gids': gid});
	}
});
</script>